package com.pengheng.handler;

import cn.hutool.json.JSONUtil;
import com.pengheng.pojo.User;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Date;

/**
 * @remark
 * @Author pengheng
 * @date 2021/5/18 11:29
 */
@Component
public class OrderReleaseOrderQueueListener {

    @RabbitListener(queues = "order.release.order.queue")
    public void listener(Message message, User user, Channel channel) throws IOException {
        System.out.println("收到消息"+ JSONUtil.toJsonStr(user)+ "时间："+new Date());
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);

    }
}
